<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            /* margin: 0; */
            padding: 0;

        }




        li {
            height: 30px;
            margin-left: 10px;
            line-height: 30px;
            color: rgb(117, 25, 25);
        }

        .style {
            text-decoration: line-through;
        }
    </style>
</head>

<body>
    <input type="text" id="box">
    <input type="submit" value="添加事项">
    <ol></ol>
    <script>
        let add = document.querySelector('[value="添加事项"]');
        let box = document.getElementById('box');
        let ol = document.querySelector('ol');
        let i;
        add.onclick = function () {
            i = box.value;
            if (i) {
                ol.innerHTML += `<li>${i}</li>`
                i.value = '';
            }
            let lis = document.querySelectorAll('li');
            for (let item of lis) {
                item.onclick = function () {
                    item.classList.toggle('style')
                }

            }
        }
    </script>
</body>

</html>